<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('房间列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="btn-group-sm" id="toolbar" role="group">
        <a class="btn btn-success" onclick="$.operate.add()">
            <i class="fa fa-plus"></i> 新增
        </a>
        <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
            <i class="fa fa-edit"></i> 修改
        </a>
        <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
            <i class="fa fa-remove"></i> 删除
        </a>
    </div>
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "hotel/room/detail";
    var roomStatus = [[${@dict.getType('hotel_room_status')}]];
    var roomTypes = [[${@dict.getType('hotel_room_type')}]];
    var hotelId = [[${hotelId}]]

    $(function() {
        var options = {
            uniqueId: 'id',
            url: prefix + "/list?hotelId=" + hotelId,
            createUrl: prefix + "/add?hotelId=" + hotelId,
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            search: true,
            modalName: "房间",
            columns: [{
                checkbox: true
            },
                {
                    field : 'roomNum',
                    title : '房间编号'
                },
                {
                    field : 'status',
                    title : '房间状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(roomStatus, value);
                    }
                },
                {
                    field : 'floor',
                    title : '房间楼层'
                },
                {
                    field : 'building',
                    title : '房间所属栋'
                },
                {
                    field : 'roomType',
                    title : '房间类型',
                    formatter: function(value, row, index){
                        return $.table.selectDictLabel(roomTypes, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-info btn-xs" href="#" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详细</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>